package com.zhmsky.controller;

import com.zhmsky.VO.InStockVO;
import com.zhmsky.entity.InStock;
import com.zhmsky.mapper.InstockMapper;
import com.zhmsky.model.ResultMap;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @description 入库记录显示
 * @author zhmsky
 * @date 2021/12/9 21:48
 */
@RestController
@RequestMapping("/InStock")
public class InstockController {
    @Autowired
    private InstockMapper instockMapper;
    @Autowired
    private ResultMap resultMap;

    /**
     * @description 查询入库记录（连表查询  关联in_stock表和supplier表）
     * @permisson admin和user角色
     * @return
     */
    @GetMapping("/getInStock")
    @RequiresRoles(logical = Logical.OR, value = {"admin", "user"})
    public ResultMap getInStock(){
        List<InStockVO> inStock = instockMapper.getInStock();
        return resultMap.success().code(200).message(inStock);
    }
}
